﻿///**********************************
/// Codeplex: http://jsprototype.codeplex.com/
/// Allrights reserved to Rynn Wang (rynn.wang@live.com)
///**********************************

String.prototype.trim = function () {
    return (this == null || this == undefined) ?
		"" :
		this.toString().replace(/^\s+/, "").replace(/\s+$/, "");
};

String.prototype.equals = function (text, ignoreCase, trim) {
    if (text != undefined && text != null) {
        text = text.toString();
        var thisValue = this.toString();
        if (trim) {
            text = text.trim();
            thisValue = thisValue.trim();
        }
        if (ignoreCase) {
            text = text.toLowerCase();
            thisValue = thisValue.toLowerCase();
        }
        return thisValue == text;
    }
    return false;
};

String.prototype.format = function () {
    var args = arguments;
    return this.replace(/\{(\d+)\}/g,
        function (m, i) {
            return args[i];
        });
}